package test.serverframe.armc.server.manager.dao.mapper;

import org.apache.ibatis.jdbc.SQL;
import test.serverframe.armc.server.manager.domain.LinkInterface;

public class LinkInterfaceSqlProvider {

    public String insertSelective(LinkInterface record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("tb_ssgp_link_interface");

        if (record.getNodeId() != null) {
            sql.VALUES("node_id", "#{nodeId,jdbcType=VARCHAR}");
        }

        if (record.getParentIds() != null) {
            sql.VALUES("parent_ids", "#{parentIds,jdbcType=VARCHAR}");
        }
        if (record.getChildIds() != null) {
            sql.VALUES("child_ids", "#{childIds,jdbcType=VARCHAR}");
        }

        if (record.getInterfaceId() != null) {
            sql.VALUES("interface_id", "#{interfaceId,jdbcType=VARCHAR}");
        }

        return sql.toString();
    }

    public String updateByPrimaryKeySelective(LinkInterface record) {
        SQL sql = new SQL();
        sql.UPDATE("tb_ssgp_link_interface");

        if (record.getParentIds() != null) {
            sql.SET("parent_ids = #{parentIds,jdbcType=VARCHAR}");
        }
        if (record.getChildIds() != null) {
            sql.SET("child_ids = #{childIds,jdbcType=VARCHAR}");
        }

        if (record.getInterfaceId() != null) {
            sql.SET("interface_id = #{interfaceId,jdbcType=VARCHAR}");
        }

        sql.WHERE("node_id = #{nodeId,jdbcType=VARCHAR}");

        return sql.toString();
    }
}